package smart.rpc.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import smart.rpc.annotation.SmartRPCAutowired;
import smart.rpc.consumer.service.ConsummerSmartRPCTestService;
import smart.rpc.producer.contract.dto.HelloDTO;
import smart.rpc.producer.contract.facade.ISmartRPCTestService;

/**
 * Created By gao_e on 2020/3/10 14:20
 */
@RestController
public class TestController {
    @Autowired
    private ConsummerSmartRPCTestService consummerSmartRPCTestService;
//    @GetMapping("/test/{name}")
//    public String test(@PathVariable("name") String name) {
//        HelloDTO helloDTO = consummerSmartRPCTestService.testRPC(name);
//        System.out.println(helloDTO);
//        return helloDTO.getHello();
//    }

    @SmartRPCAutowired
    private ISmartRPCTestService iSmartRPCTestService;

    @GetMapping("/test/{name}")
    public String test(@PathVariable("name") String name) {
        HelloDTO helloDTO = iSmartRPCTestService.hello(name);
        System.out.println(helloDTO);
        return helloDTO.getHello();
    }


}
